#!/usr/bin/python3
# -*- coding: utf-8 -*-
print( 'hello python demo3' )

#list
#**********************************************
print( '===================<list>====================' )
classmates = ['aaa', 'bbb', 'ccc']
print( 'have %d classmates, and first is %s' % (len(classmates), classmates[1]))

classmates.append('xxoo')
print('%s and length of list is %d' % (classmates, len(classmates)) )

print( classmates )
classmates.insert(1,1111)
print( classmates )
print( '===================</list>====================' )
#**********************************************

#tuple
#**********************************************
print( '===================<tuple>====================' )
fruit = ('apple', 'banana', ['orange', 'cat'])  #tuple define , looks like list, but it's content is constend pointer
print( fruit )                      #('apple', 'banana', ['orange', 'cat'])
#fruit[1] = 'lion'                   #TypeError: 'tuple' object does not support item assignment
fruit[2][1] = 'xxoo'
print( fruit )                      #it works
print( '===================</tuple>====================' )
#**********************************************

#if
#**********************************************
print( '===================<if>====================' )
#age = input('please input your age ')
#age = int(age)      #input function get the string type，int() and len() is inline funcition
age = 22
if age >= 18:
    print('adult')
elif age >= 6 and age < 18:
    print('teenager')
else:
    print('kid')

print( '===================</if>====================' )
#**********************************************

#loop
#**********************************************
print( '===================<loop>====================' )
## for loop
names = [100, 'hello', 'shit']
for i in names:
    print( i )

sum = 0
j = 0
nums = list( range(101) )
for j in nums:
    sum = sum + j
print( '0~100 sum is %s' % sum )

sum = 0
j = 0
for j in range(101):
    sum = sum + j
print( '0~100 sum is %s' % sum )

##  while loop
sum = 0
j = 100
while j > 0:
    sum = sum + j
    j = j-1
print( '0~100 sum is %s' % sum )

print( '===================</loop>====================' )
#**********************************************
